$("#querytypeName").change(function () {
    var obj = $(this);
    var typeName = obj.val();
    $.ajax({
        url:'getValueNameList.json',
        data:{
            typeName,typeName
        },
        type:'post',
        dataType:'json',
        success:function (data) {
            $("#queryValueName").html("");
            var options = "<option value=\"\">--请选择--</option>";
            for(var i = 0; i < data.length; i++){
                options += "<option value=\""+data[i].valueName+"\">"+data[i].valueName+"</option>";
            }
            $("#queryValueName").html(options);
        }
    })
})

$("#searchBtn").click(function () {
    var typeName = $("#querytypeName").val();
    var valueName = $("#queryValueName").val();
    $.ajax({
        url:'toDataDicetionary',
        data:{
            typeName:typeName,
            valueName:valueName
        }
    })
})

$("#addBtn").click(function () {
    window.location.href="toAddDataDictionary";
})

$(".deleteDataDictionaryBtn").on("click",function () {
    var obj = $(this);
    var id = obj.attr("dataDictionaryId");
    if(window.confirm("您确定要删除吗？")){
        $.ajax({
            url:'deleteDataDictionaryById',
            data:{
                id:id
            },
            type:'post',
            dataType: 'json',
            success:function (data) {
                if (data.code=="1"){
                    alert("删除成功")
                    window.location.href='toDataDicetionary';
                }else {
                    alert(data.message)
                    return;
                }
            }
        })
    }
})

$(".editDataDictionaryBtn").on("click",function () {
    var obj = $(this);
    var id = obj.attr("dataDictionaryId");
    window.location.href='toEditDataDictionary?id='+id;
})